package com.woniu.controller;

import com.woniu.entity.ProductShipment;
import com.woniu.service.ProcurePlanService;
import com.woniu.service.ProductShipmentService;
import com.woniu.util.ResponseUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
@RestController
@RequestMapping("/ps")
public class ProductShipmentController {
    @Resource
    private ProductShipmentService productShipmentService;

    // 查全部
    @GetMapping
    public ResponseUtil findAll() {
        return productShipmentService.findAll();
    }

    // 根据 procureId 查
    @GetMapping("/{shipmentId}")
    public ResponseUtil findByShipmentId(@PathVariable String shipmentId) {
        return productShipmentService.findByShipmentId(shipmentId);
    }

    // 新增
    @PostMapping
    public ResponseUtil add(@RequestBody ProductShipment productShipment) {
        return productShipmentService.add(productShipment);
    }

    // 删除
    @DeleteMapping("/{shipmentId}")
    public ResponseUtil delete(@PathVariable String shipmentId) {
        return productShipmentService.delete(shipmentId);
    }

    // 修改
    @PutMapping
    public ResponseUtil update(@RequestBody ProductShipment productShipment) {
        return productShipmentService.update(productShipment);
    }

    // 新增：条件查询接口
    @GetMapping("/condition")
    public ResponseUtil findByCondition(ProductShipment shipment) {
        return productShipmentService.findByCondition(shipment);
    }
}
